package com.party.core.model.logistics;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 物流状态枚举
 * Created by yifeng
 *
 * @date 2018/4/25 0025
 * @time 下午 14:34
 */
public enum WlLogisticsStatus {
    SHIPMENT(-1, "已发货"),

    NOT_SHIPMENT(-2, "待发货"),

    NOT_TRACK(0, "无轨迹"),

    HAVE_BEEN(1, "已揽收"),

    ON_THE_WAY(2, "在途中"),

    ONE_THE_WAY_LOCATION(201, "到达派件城市"),

    ONE_THE_WAY_ING(202, "派件中"),

    ONE_THE_WAY_IN(211, "已放入快递柜或驿站"),

    HAVE_SIGNED(3, "已签收"),

    HAVE_SIGNED_01(301, "正常签收"),

    HAVE_SIGNED_02(302, "派件异常后最终签收"),

    HAVE_SIGNED_04(304, "代收签收"),

    HAVE_SIGNED_OUT(311, "已取出快递柜或驿站"),

    PROBLEM(4, "问题件"),

    PROBLEM_NO_INFO(401, "发货无信息"),

    PROBLEM_OUT_NO_SIGNED(402, "超时未签收"),

    PROBLEM_OUT_NO_UPDATE(403, "超时未更新"),

    PROBLEM_REJECT(404, "拒收(退件)"),

    PROBLEM_05(405, "派件异常"),

    PROBLEM_06(406, "退货签收"),

    PROBLEM_07(407, "退货未签收"),

    PROBLEM_OUT_GET(412, "快递柜或驿站超时未取");


    WlLogisticsStatus(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    private Integer code;

    private String name;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    /**
     * 根据状态码获取状态值
     *
     * @param code 状态码
     * @return 状态值
     */
    public static String getValue(Integer code) {
        for (WlLogisticsStatus wlTargetType : WlLogisticsStatus.values()) {
            if (wlTargetType.getCode().equals(code)) {
                return wlTargetType.getName();
            }
        }
        return null;
    }

    /**
     * 枚举类型转换为map
     *
     * @return 转换后的map
     */
    public static Map<Integer, String> convertMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (WlLogisticsStatus wlTargetType : WlLogisticsStatus.values()) {
            map.put(wlTargetType.getCode(), wlTargetType.getName());
        }
        return map;
    }
}
